package java0819;

public class ThreadDemo12 {
    public static void main(String[] args) {
        //创建两个线程t1
        Thread t1 = new Thread(){
            @Override
            public void run() {
                int count = 0;
                while (count < 5){
                    count++;
                    System.out.println("线程运行中");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("线程运行结束");
            }
        };
        t1.start();

        try {
            Thread.sleep(7000);
            //此处join就会阻塞等待
            System.out.println("join执行开始");
            t1.join();
            System.out.println("join执行结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
